import { TRuneEffect } from "../../../Message/Db/Tables/TRuneEffect";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { DescConfig } from "./DescConfig";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class RuneEffectConfig
    
    export  class RuneEffectConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._mapById = new Map<any, any> /* flash.utils.Dictionary */();
            if (RuneEffectConfig._instance != null) 
            {
                throw new Error(" RuneEffectConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TRuneEffect();
                loc1.career = loc2.career;
                loc1.effectType = loc2.effectType;
                loc1.effectValue = loc2.effectValue;
                loc1.gainOrLoss = loc2.gainOrLoss;
                loc1.id = loc2.id;
                loc1.level = loc2.level;
                loc1.pos = loc2.pos;
                loc1.skillId = loc2.skillId;
                loc1.stateId = loc2.stateId;
                loc1.target = loc2.target;
                loc1.type = loc2.type;
                loc1.relationSkill = loc2.relationSkill;
                loc1.describe = StringHelper.getString(loc2.describe);
                loc1.descId = loc2.descId;
                if (loc1.descId > 0) 
                {
                    loc1.describe = DescConfig.instance.getDescAlyzObj(loc1.descId, loc1);
                }
                this._map[loc2.type + "_" + loc2.level] = loc1;
                this._mapById[loc2.id] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_rune_effect.json");
            this.write(loc1);
            return;
        }

        public getInfoByTypeAndLevel(arg1: int, arg2: int): TRuneEffect
        {
            return this._map[arg1 + "_" + arg2];
        }

        public getInfoByCode(arg1: int): TRuneEffect
        {
            return this._mapById[arg1];
        }

        public getInfoBySkillId(arg1: int): Array<any>
        {
            var loc2=null;
            arg1 = arg1 / 100;
            var loc1=[];
            var loc3=0;
            var loc4=this._mapById;
            for(loc2 of loc4) 
            {
                if (loc2.relationSkill != arg1) 
                {
                    continue;
                }
                loc1.push(loc2);
            }
            return loc1;
        }

        public static get instance(): RuneEffectConfig
        {
            if (RuneEffectConfig._instance == null) 
            {
                RuneEffectConfig._instance = new RuneEffectConfig();
            }
            return RuneEffectConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_mapById: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: RuneEffectConfig;
    }
